package practice;

import com.itheima.Student;

import java.util.Comparator;
import java.util.Scanner;
import java.util.TreeSet;

public class TreeSetPractice {
    public static void main(String[] args) {
//        Person person =new Person();
//        person.setName("zhangsan");
//        person.setChinese(90.0);
//        person.setEnglish(99.0);
//        person.setMath(99.5);
//        System.out.println(person);
        TreeSet<Person> ts =new TreeSet<>(new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                double result1=o2.getChinese()+o2.getMath()+ o2.getEnglish();
                double result2=o1.getChinese()+o1.getMath()+ o1.getEnglish();
                return Double.compare(result1, result2);
            }
        });
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入第" + (i+1) + "个学生信息：");
            System.out.println("请输入姓名：");
            // 录入的时候中间不能有空格
            String name = sc.next();
            System.out.println("请输入语文成绩：");
            double chinese = sc.nextDouble();
            System.out.println("请输入数学成绩：");
            double math = sc.nextDouble();
            System.out.println("请输入英语成绩：");
            double english = sc.nextDouble();
            Person p = new Person(name,chinese,math,english);
            ts.add(p);
        }
        for(Person p : ts){
            System.out.println(p);
        }
    }
}
